﻿namespace MessengerSample
{
    using System;
    using System.Globalization;
    using System.Windows;
    using System.Windows.Data;

    using Microsoft.Live.Messenger;

    public class PresenceToPersonalMessageConverter : IValueConverter
    {
        #region IValueConverter Members

        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            IMAddressPresence presence = (IMAddressPresence)value;

            string message = presence.PersonalMessage;

            if (!String.IsNullOrEmpty(message))
            {
                message = " - " + message;
            }

            return message;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotSupportedException();
        }

        #endregion
    }
}